﻿using System;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;

namespace DeliveryNotification
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            Explorer explorer = Application.ActiveExplorer();
            CommandBar commandBar =explorer.CommandBars.Add("New Toolbar", MsoBarPosition.msoBarTop, false, true);
            commandBar.Visible = true;

            CommandBarControl commandBarControl = commandBar.Controls.Add(MsoControlType.msoControlButton, 1, Type.Missing, Type.Missing, true);
            commandBarControl.Visible = true;
            commandBarControl.Caption = "New Button";

            CommandBarButton button = (CommandBarButton) commandBarControl;
            button.Click += delegate { MessageBox.Show("Hello world"); };
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        
        #endregion
    }
}
